<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/9/13
  Time: 20:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
            margin: auto;
        }
        #myid{
            width: 500px;
            height: 320px;
            background-color: rgb(235, 235, 235);
        }
        #myid h1{
            font-family: '仿宋';
            text-align: center;
        }
        #myid label{
            width: 100px;
            height: 20px;
            display: inline-block;
            text-align: right;
            font-size: 14px;
            margin-bottom: 10px;
            margin-left: 20px;
        }
        #myid span{
            font-size: 12px;
        }
        #myid div{
            display: inline-block;
            width: 180px;
            height: 20px;
            color: red;
            font-size: 12px;
            margin-left: 5px;
            /*border: 1px solid red;*/
        }
        #myid #t1{
            margin-top: 20px;
        }
        [type=submit]{
            width: 100px;
            height: 30px;
            background-color: pink;
            border: 1px solid pink;
            color: #fff;
            margin-left: 120px;
        }
        [type=button]{
            width: 100px;
            height: 30px;
            background-color: pink;
            border: 1px solid pink;
            color: #fff;
            margin-left: 10px;
        }
    </style>
</head>
<body>
<%
    Cookie[] cookies = request.getCookies();
    if(cookies != null){
        for(int i = 0 ; i < cookies.length ; i++ ){
            if(cookies[i].getName().equals("username")){
                session.setAttribute("name", cookies[i].getValue());
                response.sendRedirect("NewFile2.jsp");
            }
        }
    }

%>
<form id="form1" action="doLogin" method='post'>
    <div id='myid'>
        <br><br>
        <h1>用户登录</h1>
        <br>
        <label for="t1">账号：</label>
        <input type="text" id='t1' name="userNum">
        <div id='d1'></div>
        <br><br>
        <label for="t2">密码：</label>
        <input type="password" id='t2' name="userPass">
        <div id='d2'></div>
        <br><br>
        <input type="submit" value='登录' id='sub'>
        <input type="button" value='注册' id='res' onclick="changeAction('register.jsp')">
    </div>
</form>
</body>
        <script>
            function $(id){
                return document.getElementById(id);
            }

            function changeAction(url){
                $("form1").action=url;
                $("form1").submit();
            }
        </script>
</html>
